home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / incl / LEDA.020+881 / _Point1.h < prev    next >
C/C++ Source or Header  |  1994-08-05  |  3KB  |  133 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  Point1.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_POINTEXACT_H
  16. #define LEDA_POINTEXACT_H
  17.  
  18. #include <LEDA/list.h>
  19. #include <LEDA/vector.h>
  20. #include <LEDA/Int.h>
  21.  
  22. class Point;
  23. class Segment;
  24.  
  25.  
  26. //------------------------------------------------------------------------------
  27. // Points
  28. //------------------------------------------------------------------------------
  29.  
  30. class Point_rep  : public handle_rep {
  31.  
  32. friend class Point;
  33. friend class Segment;
  34. friend class Line;
  35. friend class Circle;
  36.    
  37.    Int x;
  38.    Int y;
  39.    Int w;
  40.  
  41. public:
  42.     
  43.    Point_rep();     
  44.    Point_rep(Int a, Int b);
  45.    Point_rep(Int a, Int b, Int c);
  46.  
  47.   ~Point_rep() {}
  48.    
  49.    
  50.    LEDA_MEMORY(Point_rep)
  51.    
  52. };
  53.  
  54.  
  55. class Point  : public handle_base 
  56. {
  57.  
  58. friend class Segment;
  59. friend class Line;
  60. friend class Circle;
  61.  
  62.  
  63. Point_rep* ptr() const { return (Point_rep*)PTR; }   //does type casting
  64.  
  65. public:
  66.  
  67.  Point();
  68.  Point(Int, Int);
  69.  Point(Int, Int, Int);
  70. // Point(vector);
  71.  Point(const Point& p) : handle_base(p) {}  //increase reference counter by one
  72. ~Point()                  { clear(); }
  73.  
  74. Point& operator=(const Point& p) { handle_base::operator=(p); return *this; }
  75.  
  76.  
  77. //operator vector()         { return vector(ptr()->x,ptr()->y); }
  78.  
  79. double xcoord() const { return Itodouble(ptr()->x)/Itodouble(ptr()->w);}
  80. double ycoord() const { return Itodouble(ptr()->y)/Itodouble(ptr()->w);}
  81.  
  82. #if defined(__GNUG__)
  83. Int X() const { return ptr()->x; }
  84. Int Y() const { return ptr()->y; }
  85. Int W() const { return ptr()->w; }
  86. #else
  87. const Int& X() const { return ptr()->x; }
  88. const Int& Y() const { return ptr()->y; }
  89. const Int& W() const { return ptr()->w; }
  90. #endif
  91.  
  92. double XD() const { return Itodouble(ptr()->x); }
  93. double YD() const { return Itodouble(ptr()->y); }
  94. double WD() const { return Itodouble(ptr()->w); }
  95.  
  96. //double  angle(const Point&, const Point&) const;
  97.  
  98. //double  distance(const Point&) const;
  99. //double  distance() const;
  100.  
  101. //Point   translate(double,double) const;
  102. //Point   translate(const vector&) const;
  103.  
  104. //Point   rotate(const Point&,double) const;
  105. //Point   rotate(double) const;
  106.  
  107.  
  108. //Point operator+(const vector& v) const { return translate(v); }
  109.  
  110. int operator==(const Point&) const;
  111.  
  112. int operator!=(const Point& p)  const { return !operator==(p);}
  113.  
  114. friend ostream& operator<<(ostream& out, const Point& p) ;
  115. friend istream& operator>>(istream& in, Point& p) ;
  116.  
  117. friend void Print(const Point&, ostream& = cout);
  118. friend void Read(Point&,  istream& = cin);
  119. /*
  120. friend int  compare(const Point&, const Point&);
  121. */
  122.  
  123. };
  124.  
  125. inline void Print(const Point& p, ostream& out) { out << p; } 
  126. inline void Read(Point& p,  istream& in)        { in >> p; }
  127.  
  128. LEDA_HANDLE_TYPE(Point)
  129.  
  130. #endif
  131.  
  132.